package com.glsc.ngateway.common.base.converter.platform;

import com.alibaba.excel.util.CollectionUtils;
import com.glsc.ngateway.common.api.flowable.dto.FlowFormCPUOutDetailDto;
import com.glsc.ngateway.common.base.domain.mysql.gateway.platform.flow.cmdb.FlowFormCPUOutDetail;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;

/**
 * @author xuchang
 */
public class FlowFormCPUOutDetailConverter {

    public static FlowFormCPUOutDetailDto do2Dto(FlowFormCPUOutDetail domain) {
        if (Objects.isNull(domain)) {
            return null;
        }
        FlowFormCPUOutDetailDto dto = FlowFormCPUOutDetailMapper.INSTANCE.do2Dto(domain);
        return dto;
    }

    public static List<FlowFormCPUOutDetailDto> do2Dto(List<FlowFormCPUOutDetail> domainList) {
        return CollectionUtils.isEmpty(domainList) ? java.util.Collections.emptyList() : domainList.stream().map(FlowFormCPUOutDetailConverter::do2Dto).collect(Collectors.toList());
    }

    public static FlowFormCPUOutDetail dto2Do(FlowFormCPUOutDetailDto dto) {
        if (Objects.isNull(dto)) {
            return null;
        }
        FlowFormCPUOutDetail domain = FlowFormCPUOutDetailMapper.INSTANCE.dto2Do(dto);
        return domain;
    }

    public static List<FlowFormCPUOutDetail> dto2Do(List<FlowFormCPUOutDetailDto> dtoList) {
        return CollectionUtils.isEmpty(dtoList) ? java.util.Collections.emptyList() : dtoList.stream().map(FlowFormCPUOutDetailConverter::dto2Do).collect(Collectors.toList());
    }

    @Mapper(componentModel = "spring")
    public interface FlowFormCPUOutDetailMapper {

        FlowFormCPUOutDetailMapper INSTANCE = Mappers.getMapper(FlowFormCPUOutDetailMapper.class);

        FlowFormCPUOutDetailDto do2Dto(FlowFormCPUOutDetail domain);

        List<FlowFormCPUOutDetailDto> do2Dto(List<FlowFormCPUOutDetail> domain);

        FlowFormCPUOutDetail dto2Do(FlowFormCPUOutDetailDto dto);

        List<FlowFormCPUOutDetail> dto2Do(List<FlowFormCPUOutDetailDto> dto);
    }
}
